package com.yonyou.isv.demo.openapi.api.role;

import com.yonyou.isv.demo.openapi.api.*;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataArrayResponse;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataArrayStringResponse;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataResponse;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @description: 用友开放平台接口角色管理
 * @author: zpp
 * @create: 2021-07-26
 **/
@Component
public class RoleApi extends BaseOpenApi {
    /**
     * 保存角色
     * @param params
     * @return
     */
    public Map<String, Object> save(Map<String, Object> params) {
        ApiDataResponse apiDataResponse =  postForEntity(OpenApiURL.ROLE_SAVE,params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 保存用户角色
     */
    public Map<String,Object> userSave(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.ROLE_USERSAVE, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 租户下用户身份列表查询
     */
    public Map<String,Object> users(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.ROLE_USERS, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 租户下的角色列表
     */
    public List<Map<String,Object>> list(Map<String,Object> params)
    {
        ApiDataArrayResponse apiDataResponse = postForEntity(OpenApiURL.ROLE_LIST, params, ApiDataArrayResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 查询角色关联的用户身份
     */
    public Map<String,Object> userByRole(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.ROLE_USERSBYROLE, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 根据ID查角色
     */
    public Map<String,Object> query(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.ROLE_QUERY, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 批量保存用户角色
     */
    public List<Map<String,Object>> bacthSave(Map<String,Object> params)
    {
        ApiDataArrayResponse apiDataResponse = postForEntity(OpenApiURL.ROLE_BACTHSAVE, params, ApiDataArrayResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 删除角色关联的用户数组
     */
    public Map<String,Object> deleteUser(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.ROLE_DETELETUSER, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 主组织权限查询
     */
    public List<String> mainOrgPermission(Map<String,Object> params)
    {
        ApiDataArrayStringResponse apiDataArrayResponse = postForEntity(OpenApiURL.ROLE_MAINORGPERMISSION, params, ApiDataArrayStringResponse.class);
        return getData(apiDataArrayResponse);
    }
}
